import React, {Component} from 'react';
import {
    View,
    Text,
    Image,
    TouchableOpacity,
} from 'react-native';

import {systopStyle as styles} from '../../../../styles';
import Icon from 'react-native-vector-icons/Ionicons';
import Resume from '../resume/Resume';
import {common_url, fetchRequest} from "../../../util/fetch";


var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;


export default class Sysbasic extends Component {

    constructor(props) {            //构造器只执行一次
        super(props);
        this.state = {
            count: 0,
        };
        this.noReadCount();
    };

    render() {
        return (
            <View>
                <View style={[styles.top, {width: width * 1}]}>
                    <View style={[styles.topin, {width: width * 0.8}]}>
                        <View style={styles.left}>
                            <Text style={styles.name}>{this.props.resume.resumeName}</Text>
                            <Text style={styles.text}>{this.props.resume.resumeField}</Text>
                            <Text style={styles.text2}>{this.props.resume.resumePosition}</Text>
                        </View>
                        <Image source={
                            this.props.resume.resumeIntentField ?
                                {uri: common_url + "uploadImg/" + this.props.resume.resumeIntentField}
                                : require('../../../img/app/boy2.png')} style={styles.head}/>
                    </View>

                    <View style={[styles.pituall, {width: width * 0.95}]}>

                        <TouchableOpacity
                            activeOpacity={1}
                            style={styles.pitu}
                            onPress={() => {
                                this.props.navigation.navigate('Resume')
                            }}
                        >
                            <Icon
                                name={'md-bookmarks'}
                                size={28}
                                color={'#ffffff'}/>
                            <Text style={styles.icont}>我的简历</Text>
                        </TouchableOpacity>

                        <TouchableOpacity style={styles.pitu} activeOpacity={1} onPress={() => {
                            this.props.navigation.navigate('Newsall', {noReadCount: this.noReadCount.bind(this)})
                        }}>
                            <Icon
                                name={'md-notifications'}
                                size={28}
                                color={'#ffffff'}/>
                            <Text style={styles.icont}>我的消息</Text>
                            {this.state.count === 0 || <Text style={styles.numall}>{this.state.count}</Text>}
                        </TouchableOpacity>

                        <TouchableOpacity style={styles.pitu} activeOpacity={1} onPress={() => {
                            this.props.navigation.navigate('Information')
                        }}>
                            <Icon
                                name={'md-person'}
                                size={28}
                                color={'#ffffff'}/>
                            <Text style={styles.icont}>个人信息</Text>
                        </TouchableOpacity>
                        <TouchableOpacity style={styles.pitu} activeOpacity={1} onPress={() => {
                            this.props.navigation.navigate('Browseall')
                        }}>
                            <Icon
                                name={'ios-time'}
                                size={28}
                                color={'#ffffff'}/>
                            <Text style={styles.icont}>最近浏览</Text>
                        </TouchableOpacity>
                    </View>
                </View>
            </View>
        )
    }

    noReadCount() {
        fetchRequest('xzMsg/noReadCount.go', 'POST', {}).then(
            res => this.setState({count: res.count})
        );
    }

}